#include "ItemFactory.h"

void Factory::initAssets()
{
	m_artAssets[alpha]			= addAsset("Resources/Meshes/character mesh.X"	,"Resources/Sprites/Alpha.png"			, NULL, NULL, ASSET_WORLD);
	m_artAssets[collider]		= addAsset("Resources/Meshes/collider.X"		,"Resources/Sprites/Tracer.png"		, NULL, NULL, ASSET_WORLD);
	m_artAssets[fireBall]		= addAsset("Resources/Meshes/collider.X"		,"Resources/Sprites/Fireball.png"		, NULL, NULL, ASSET_WORLD);

	m_artAssets[bowieKnife]		= addAsset("Resources/Meshes/character mesh.X"	,"Resources/Sprites/Entity/DaggerS.png"	, NULL, NULL, ASSET_WORLD);
	m_artAssets[energyMace]		= addAsset("Resources/Meshes/character mesh.X"	,"Resources/Sprites/Entity/Energy Mace.png"	, NULL, NULL, ASSET_WORLD);
	m_artAssets[handGun]		= addAsset("Resources/Meshes/character mesh.X"	,"Resources/Sprites/Entity/Handgun.png"	, NULL, NULL, ASSET_WORLD);
	m_artAssets[ehandGun]		= addAsset("Resources/Meshes/character mesh.X"	,"Resources/Sprites/Entity/eHandgun.png"	, NULL, NULL, ASSET_WORLD);
	m_artAssets[magRifle]		= addAsset("Resources/Meshes/torso.X"			,"Resources/Sprites/Entity/Magrifle.png"	, NULL, NULL, ASSET_WORLD);
	m_artAssets[ironCuirass]	= addAsset("Resources/Meshes/torso.X"			,"Resources/Sprites/Armor/Inorite/Cuirass.png", NULL, NULL, ASSET_WORLD);
	m_artAssets[ironHand]		= addAsset("Resources/Meshes/character mesh.X"	,"Resources/Sprites/Armor/Inorite/Hand.png"	, NULL, NULL, ASSET_WORLD);
	m_artAssets[ironArm]		= addAsset("Resources/Meshes/character mesh.X"	,"Resources/Sprites/Armor/Inorite/Arm.png"	, NULL, NULL, ASSET_WORLD);
	m_artAssets[ironFoot]		= addAsset("Resources/Meshes/character mesh.X"	,"Resources/Sprites/Armor/Inorite/Boot.png"	, NULL, NULL, ASSET_WORLD);
	m_artAssets[ironThigh]		= addAsset("Resources/Meshes/character mesh.X"	,"Resources/Sprites/Armor/Inorite/Thigh.png"	, NULL, NULL, ASSET_WORLD);
	m_artAssets[ironHelm]		= addAsset("Resources/Meshes/character mesh.X"	,"Resources/Sprites/Armor/Inorite/Helm.png"	, NULL, NULL, ASSET_WORLD);

	m_artAssets[mharysCuirass]	= addAsset("Resources/Meshes/torso.X"			,"Resources/Sprites/Armor/Mharys/Cuirass.png", NULL, NULL, ASSET_WORLD);
	m_artAssets[mharysHand]		= addAsset("Resources/Meshes/character mesh.X"	,"Resources/Sprites/Armor/Mharys/Hand.png"	, NULL, NULL, ASSET_WORLD);
	m_artAssets[mharysArm]		= addAsset("Resources/Meshes/character mesh.X"	,"Resources/Sprites/Armor/Mharys/Arm.png"	, NULL, NULL, ASSET_WORLD);
	m_artAssets[mharysFoot]		= addAsset("Resources/Meshes/character mesh.X"	,"Resources/Sprites/Armor/Mharys/Boot.png"	, NULL, NULL, ASSET_WORLD);
	m_artAssets[mharysThigh]	= addAsset("Resources/Meshes/character mesh.X"	,"Resources/Sprites/Armor/Mharys/Thigh.png"	, NULL, NULL, ASSET_WORLD);
	m_artAssets[mharysHelm]		= addAsset("Resources/Meshes/character mesh.X"	,"Resources/Sprites/Armor/Mharys/Helm.png"	, NULL, NULL, ASSET_WORLD);

	m_artAssets[carbitaniumCuirass]	= addAsset("Resources/Meshes/torso.X"			,"Resources/Sprites/Armor/Carbitanium/Cuirass.png", NULL, NULL, ASSET_WORLD);
	m_artAssets[carbitaniumHand]	= addAsset("Resources/Meshes/character mesh.X"	,"Resources/Sprites/Armor/Carbitanium/Hand.png"	, NULL, NULL, ASSET_WORLD);
	m_artAssets[carbitaniumArm]		= addAsset("Resources/Meshes/character mesh.X"	,"Resources/Sprites/Armor/Carbitanium/Arm.png"	, NULL, NULL, ASSET_WORLD);
	m_artAssets[carbitaniumFoot]	= addAsset("Resources/Meshes/character mesh.X"	,"Resources/Sprites/Armor/Carbitanium/Boot.png"	, NULL, NULL, ASSET_WORLD);
	m_artAssets[carbitaniumThigh]	= addAsset("Resources/Meshes/character mesh.X"	,"Resources/Sprites/Armor/Carbitanium/Thigh.png"	, NULL, NULL, ASSET_WORLD);
	m_artAssets[carbitaniumHelm]	= addAsset("Resources/Meshes/character mesh.X"	,"Resources/Sprites/Armor/Carbitanium/Helm.png"	, NULL, NULL, ASSET_WORLD);

	m_iconAssets[alpha]			= addAsset("Resources/Sprites/Alpha.png"				, NULL, NULL, ASSET_GUI);

	m_iconAssets[bowieKnife]	= addAsset("Resources/Sprites/Icons/Bowie_Knife.png"	, NULL, NULL, ASSET_GUI);
	m_iconAssets[energyMace]	= addAsset("Resources/Sprites/Icons/iEnergymace.png"	, NULL, NULL, ASSET_GUI);
	m_iconAssets[handGun]		= addAsset("Resources/Sprites/Icons/iHandgun.png"		, NULL, NULL, ASSET_GUI);
	m_iconAssets[ehandGun]		= addAsset("Resources/Sprites/Icons/ieHandgun.png"		, NULL, NULL, ASSET_GUI);
	m_iconAssets[magRifle]		= addAsset("Resources/Sprites/Icons/iMagrifle.png"		, NULL, NULL, ASSET_GUI);

	m_iconAssets[ironCuirass]	= addAsset("Resources/Sprites/Icons/Inorite/Cuirass.png", NULL, NULL, ASSET_GUI);
	m_iconAssets[ironHand]		= addAsset("Resources/Sprites/Icons/Inorite/Hand.png"	, NULL, NULL, ASSET_GUI);
	m_iconAssets[ironFoot]		= addAsset("Resources/Sprites/Icons/Inorite/Foot.png"	, NULL, NULL, ASSET_GUI);
	m_iconAssets[ironHelm]		= addAsset("Resources/Sprites/Icons/Inorite/Helm.png"	, NULL, NULL, ASSET_GUI);

	m_iconAssets[mharysCuirass]	= addAsset("Resources/Sprites/Icons/Mharys/Cuirass.png"	, NULL, NULL, ASSET_GUI);
	m_iconAssets[mharysHand]	= addAsset("Resources/Sprites/Icons/Mharys/Hand.png"	, NULL, NULL, ASSET_GUI);
	m_iconAssets[mharysFoot]	= addAsset("Resources/Sprites/Icons/Mharys/Foot.png"	, NULL, NULL, ASSET_GUI);
	m_iconAssets[mharysHelm]	= addAsset("Resources/Sprites/Icons/Mharys/Helm.png"	, NULL, NULL, ASSET_GUI);

	m_iconAssets[carbitaniumCuirass]= addAsset("Resources/Sprites/Icons/Carbitanium/Cuirass.png", NULL, NULL, ASSET_GUI);
	m_iconAssets[carbitaniumHand]	= addAsset("Resources/Sprites/Icons/Carbitanium/Hand.png"	, NULL, NULL, ASSET_GUI);
	m_iconAssets[carbitaniumFoot]	= addAsset("Resources/Sprites/Icons/Carbitanium/Boot.png"	, NULL, NULL, ASSET_GUI);
	m_iconAssets[carbitaniumHelm]	= addAsset("Resources/Sprites/Icons/Carbitanium/Helm.png"	, NULL, NULL, ASSET_GUI);

	m_iconAssets[medOsazine]	= addAsset("Resources/Sprites/Icons/iOsazine.png"	, NULL, NULL, ASSET_GUI);
	m_iconAssets[medAdrenelol]	= addAsset("Resources/Sprites/Icons/iAdrenelol.png"	, NULL, NULL, ASSET_GUI);
	m_iconAssets[medMetazine]	= addAsset("Resources/Sprites/Icons/iMetazine.png"	, NULL, NULL, ASSET_GUI);

	m_iconAssets[mInoriteBar]	= addAsset("Resources/Sprites/Icons/Metals/iInoriteBar.png"		, NULL, NULL, ASSET_GUI);
	m_iconAssets[mInoriteIngot]	= addAsset("Resources/Sprites/Icons/Metals/iInoriteIngot.png"	, NULL, NULL, ASSET_GUI);
	m_iconAssets[mInoriteWafer]	= addAsset("Resources/Sprites/Icons/Metals/iInoriteWafer.png"	, NULL, NULL, ASSET_GUI);
	m_iconAssets[mInoriteBillet]= addAsset("Resources/Sprites/Icons/Metals/iInoriteBillet.png"	, NULL, NULL, ASSET_GUI);
	m_iconAssets[mTurfPaste]	= addAsset("Resources/Sprites/Icons/Pastes/iTurfPaste.png"		, NULL, NULL, ASSET_WORLD);
	m_iconAssets[mFoamGel]		= addAsset("Resources/Sprites/Icons/Pastes/iFoamGel.png"		, NULL, NULL, ASSET_WORLD);
	
	m_iconAssets[mResin]		= addAsset("Resources/Sprites/Icons/Pastes/iResin.png"		, NULL, NULL, ASSET_WORLD);
	m_iconAssets[mEnergySalve]	= addAsset("Resources/Sprites/Icons/Pastes/iEnergySalve.png"	, NULL, NULL, ASSET_WORLD);
	m_iconAssets[mAlgaeCluster]	= addAsset("Resources/Sprites/Icons/Pastes/iAlgaeCluster.png", NULL, NULL, ASSET_WORLD);
	m_iconAssets[mEarthFlesh]	= addAsset("Resources/Sprites/Icons/Pastes/iEarthFlesh.png"	, NULL, NULL, ASSET_WORLD);
	m_iconAssets[mMetalPlate]	= addAsset("Resources/Sprites/Icons/Pastes/iMetalPlate.png"	, NULL, NULL, ASSET_WORLD);
	m_iconAssets[mConductor]	= addAsset("Resources/Sprites/Icons/Pastes/iConductor.png"	, NULL, NULL, ASSET_WORLD);
	m_iconAssets[mEnergyNode]	= addAsset("Resources/Sprites/Icons/Pastes/iEnergyNode.png"	, NULL, NULL, ASSET_WORLD);
	m_iconAssets[mNanoGel]		= addAsset("Resources/Sprites/Icons/Pastes/iNanoGel.png"		, NULL, NULL, ASSET_WORLD);
	initOriginalCopies();

	for(int i=0; i < projectilePool.size(); i++)
	{
		projectilePool.get(i).itemType = ITEM_NULL;
	}
}

Item_Equippable* Factory::initEquippable(char* fileName, int item)
{
	Item_Equippable* newItem = (Item_Equippable*)(create(ITEM_EQUIPPABLE));
	newItem->assetIndex = m_artAssets[item];
	newItem->iconAsset	= m_iconAssets[item];
	newItem->_fileInit(fileName,&recipeBook[item]);

	if(newItem->getEquipType() == FIST || newItem->getEquipType() == BOOT)
		newItem->secassetIndex = Vector2D(newItem->assetIndex.x, newItem->assetIndex.y + 1); 

	return newItem;
}
Item_Consumable* Factory::initConsumable(char* fileName, int item)
{
	Item_Consumable* newItem = (Item_Consumable*)(create(ITEM_CONSUMABLE));
	newItem->assetIndex = m_artAssets[item];
	newItem->iconAsset	= m_iconAssets[item];
	newItem->itemType   = ITEM_CONSUMABLE;
	newItem->_fileInit(fileName,&recipeBook[item]);
	return newItem;
}
Item_Equippable* Factory::initMaterial(char* fileName,int item)
{
	Item_Equippable* newItem = (Item_Equippable*)(create(ITEM_EQUIPPABLE));
	newItem->assetIndex = m_artAssets[item];
	newItem->iconAsset	= m_iconAssets[item];
	newItem->_fileInit(fileName,&recipeBook[item]);
	return newItem;
}


void Factory::initOriginalCopies()
{
	for(int i = 0; i < ITEM_SIZE; i++)
		m_originalCopy[i] = NULL;

	m_originalCopy[bowieKnife]		= initEquippable("Resources/Prebuilds/Items/bowie_knife.txt"			,bowieKnife);
	m_originalCopy[energyMace]		= initEquippable("Resources/Prebuilds/Items/Energy_Mace.txt"			,energyMace);
	m_originalCopy[handGun]			= initEquippable("Resources/Prebuilds/Items/Handgun.txt"				,handGun);
	m_originalCopy[ehandGun]		= initEquippable("Resources/Prebuilds/Items/eHandgun.txt"				,ehandGun);
	m_originalCopy[magRifle]		= initEquippable("Resources/Prebuilds/Items/Magrifle.txt"				,magRifle);

	m_originalCopy[ironCuirass]		= initEquippable("Resources/Prebuilds/Items/Armor/Inorite/cuirass.txt"	,ironCuirass);
	m_originalCopy[ironHand]		= initEquippable("Resources/Prebuilds/Items/Armor/Inorite/hand.txt"		,ironHand);
	m_originalCopy[ironFoot]		= initEquippable("Resources/Prebuilds/Items/Armor/Inorite/boots.txt"	,ironFoot);
	m_originalCopy[ironHelm]		= initEquippable("Resources/Prebuilds/Items/Armor/Inorite/helm.txt"		,ironHelm);

	m_originalCopy[mharysCuirass]	= initEquippable("Resources/Prebuilds/Items/Armor/Mharys/cuirass.txt"	,mharysCuirass);
	m_originalCopy[mharysHand]		= initEquippable("Resources/Prebuilds/Items/Armor/Mharys/hand.txt"		,mharysHand);
	m_originalCopy[mharysFoot]		= initEquippable("Resources/Prebuilds/Items/Armor/Mharys/boots.txt"		,mharysFoot);
	m_originalCopy[mharysHelm]		= initEquippable("Resources/Prebuilds/Items/Armor/Mharys/helm.txt"		,mharysHelm);

	m_originalCopy[carbitaniumCuirass]	= initEquippable("Resources/Prebuilds/Items/Armor/Carbitanium/cuirass.txt"	,carbitaniumCuirass);
	m_originalCopy[carbitaniumHand]		= initEquippable("Resources/Prebuilds/Items/Armor/Carbitanium/hand.txt"		,carbitaniumHand);
	m_originalCopy[carbitaniumFoot]		= initEquippable("Resources/Prebuilds/Items/Armor/Carbitanium/boots.txt"	,carbitaniumFoot);
	m_originalCopy[carbitaniumHelm]		= initEquippable("Resources/Prebuilds/Items/Armor/Carbitanium/helm.txt"		,carbitaniumHelm);

	m_originalCopy[medAdrenelol]	= initConsumable("Resources/Prebuilds/Items/cAdrenalol.txt"		,medAdrenelol);
	m_originalCopy[medOsazine]		= initConsumable("Resources/Prebuilds/Items/cOsazine.txt"		,medOsazine);
	m_originalCopy[medMetazine]		= initConsumable("Resources/Prebuilds/Items/cMetazine.txt"		,medMetazine);
	m_originalCopy[mInoriteBar]		= initMaterial("Resources/Prebuilds/Items/mInoriteBar.txt"			,mInoriteBar);
	m_originalCopy[mInoriteIngot]	= initMaterial("Resources/Prebuilds/Items/mInoriteIngot.txt"		,mInoriteIngot);
	m_originalCopy[mInoriteWafer]	= initMaterial("Resources/Prebuilds/Items/mInoriteWafer.txt"		,mInoriteWafer);
	m_originalCopy[mInoriteBillet]	= initMaterial("Resources/Prebuilds/Items/mInoriteBillet.txt"		,mInoriteBillet);

	m_originalCopy[mTurfPaste]		= initMaterial("Resources/Prebuilds/Items/mTurfPaste.txt"			,mTurfPaste);
	m_originalCopy[mFoamGel]		= initMaterial("Resources/Prebuilds/Items/mFoamGel.txt"				,mFoamGel);
	m_originalCopy[mResin]			= initMaterial("Resources/Prebuilds/Items/mResin.txt"				,mResin);
	m_originalCopy[mEnergySalve]	= initMaterial("Resources/Prebuilds/Items/mEnergySalve.txt"			,mEnergySalve);
	m_originalCopy[mAlgaeCluster]	= initMaterial("Resources/Prebuilds/Items/mAlgaeCluster.txt"		,mAlgaeCluster);
	m_originalCopy[mEarthFlesh]		= initMaterial("Resources/Prebuilds/Items/mEarthFlesh.txt"			,mEarthFlesh);
	m_originalCopy[mMetalPlate]		= initMaterial("Resources/Prebuilds/Items/mMetalPlate.txt"			,mMetalPlate);
	m_originalCopy[mConductor]		= initMaterial("Resources/Prebuilds/Items/mConductor.txt"			,mConductor);
	m_originalCopy[mEnergyNode]		= initMaterial("Resources/Prebuilds/Items/mEnergyDiode.txt"			,mEnergyNode);
	m_originalCopy[mNanoGel]		= initMaterial("Resources/Prebuilds/Items/mNanoGel.txt"				,mNanoGel);



};